package com.ly.mpayment.rest.system;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.core.Context;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.ly.mpayment.core.util.JsonUtils;
import com.ly.mpayment.core.util.MapUtil;
import com.ly.mpayment.core.util.ResultMessage;
import com.ly.mpayment.core.util.StringUtils;
import com.ly.mpayment.persist.service.uporderlog.IUpOrderLogService;
import com.ly.mpayment.persist.service.user.IUserService;
import com.ly.mpayment.rest.AbsRest;

import net.sf.json.JSONObject;

@Component
@Path("system/upOrderLog/")
public class UpOrderLogRest extends AbsRest {

	@Autowired
	IUserService userService;
	@Autowired
	IUpOrderLogService logService;

	@SuppressWarnings("static-access")
	@Path("findPageUpOrderLog")
	@POST
	public String findPageUpOrderLog(String data,@Context HttpServletRequest request){
		String result = this.validationParameterGetRole( request, userService);
		if(result == null){
			JSONObject json = JsonUtils.getJSONOBJCT().fromObject(data);
			Map<String, Object> maps = MapUtil.getMap();
			if(!StringUtils.isBlank(json.getString("phoneNum"))){
				maps.put(":phoneNum", json.getString("phoneNum"));
			}
			if(!StringUtils.isBlank(json.getString("starttime"))){
				maps.put(":starttime", json.getString("starttime"));
			}
			if(!StringUtils.isBlank(json.getString("endtime"))){
				maps.put(":endtime", json.getString("endtime"));
			}
			if(!StringUtils.isBlank(json.getString("useruuid"))){
				maps.put(":useruuid", json.getString("useruuid"));
			}
			return ResultMessage.getSucceed( JsonUtils.excludes(logService.findPageUporderlog(maps, json.getInt("start"), json.getInt("pageSize")),
					new String[]{"upgameRecharge","user","information","downRechargeFlow","upShopPro"
							,"userOrder","operators","status","","statusremark","upOrderId",
							"upendtime","","rechargeamount","discount","uprechargenum","childOrder"
							,"upOrderRefunds","upOrderLogs","discountAmount","sendStatus","downShopName",
							"callBack","upendtimesec"}));

		}
		return result;
	}
}
